home *** CD-ROM | disk | FTP | other *** search
- /*
- * JPEG Convert.h
- *
- * Copyright (C) 1992, James H. Brunner.
- *
- * This file is part of the "JPEG Convert" program. The JPEG Convert program signature ('Ijgp')
- * and unique file types ('TARG', 'RLE ', 'PPM ') are registered with Apple by the author.
- *
- * The JPEG Convert program is an image format conversion program that utilizes the software of
- * the Independent JPEG Group. The JPEG Convert program is essentially a Macintosh user interface
- * around the Independent JPEG Group's code. The author of JPEG Convert maintains a copyright to
- * the interface software only. For conditions of distribution and use of the Independent JPEG
- * Group's software, refer to the README file contained in the Independent JPEG Group's distribution
- * package.
- *
- * (Further use of the word 'software' refers only to the source files for implementing this user
- * interface, including the resource file which does not include this comment. It does NOT refer
- * to the Independent JPEG Group's code.)
- *
- * The conditions for distribution of this software are as follows:
- * This software may be freely distributed provided that it is not distributed for profit; a
- * nominal copying fee may be charged.
- *
- * Any distribution of this software must contain all original copyright notices.
- *
- * The conditions for use of this software IN FULL are as follows:
- * This software may be used in full by any person or business provided that the person or
- * business is not seeking profits directly from the use of this software.
- *
- * The conditions for use of this software IN PART are as follows:
- * Any person or business may copy and utilize portions of this software in other products
- * provided that a note that "portions of the software are copyright by James H. Brunner"
- * is included in the software AND the resultant software is not intended to be distributed
- * for profit.
- *
- * If SOURCE for projects containing portions of this code is not to be made available
- * with the resultant programs, an additional note that "portions of the software are
- * copyright James H. Brunner" must be included in some visable user documentation.
- *
- * Bottom line: I give it away free; I don't want you selling it. You can use the source if
- * you wish, but don't sell it. If you use my work, give me credit for it.
- */
-
- /*
- * JPEG Convert.h
- *
- * This header file contains common information between the other source files that implement the
- * interface. I did not use "MacHeaders" because, since I'm distributing this as source, I don't
- * know what other folks have done to their MacHeader file.
- */
-
- /* MAC INCLUDES */
- #include <Dialogs.h>
- #include <Think.h>
- #include <ToolUtils.h>
- #include <AppleEvents.h>
- #include <Types.h>
- #include <StandardFile.h>
- #include <Pascal.h>
- #include <Errors.h>
- #include <Resources.h>
-
- /* INDEPENDENT JPEG GROUP INCLUDES */
- #include "jinclude.h"
-
- /* This is the application signature that is registered with Apple Computer */
- #define appSignature 'Ijgp'
-
- /* MISC DEFINES */
- #define MAXINT 32767
-
- /* DEFINES FOR DIALOG ITEMS IN THE CJPEG AND DJPEG DIALOGS */
- #define J_OK 1
- #define J_OK_ALL 2
- #define J_CAN 3
- #define J_SETFILE 4
- #define J_INFILE 5
- #define J_OUTFILE 6
- #define CJ_QUALITY 7
- #define CJ_OPT 8
- #define CJ_GRAY 9
- #define CJ_TARGA 10
- #define CJ_NONINTER 11
- #define CJ_ARITH 12
- #define CJ_DEBUG 13
- #define CJ_OKBORDER 19
- #define DJ_GIF 7
- #define DJ_PPM 8
- #define DJ_RLE 9
- #define DJ_TARGA 10
- #define DJ_QUANTIZE 11
- #define DJ_Q_COLORS 12
- #define DJ_Q_NODITHER 13
- #define DJ_Q_1PASS 14
- #define DJ_GRAY 15
- #define DJ_SMOOTH 16
- #define DJ_DEBUG 17
- #define DJ_OKBORDER 24
- #define DJ_DIMCOLORS 25
-
- /* DEFINE DIFFERENT OUTPUT FILE FORMATS */
- typedef enum {
- FMT_GIF=DJ_GIF, /* GIF format */
- FMT_PPM, /* PPM/PGM (PBMPLUS formats) */
- FMT_RLE, /* RLE format */
- FMT_TARGA, /* Targa format */
- FMT_JPEG
- } ImageFormat;
-
- #ifndef DEFAULT_FMT /* so can override from prefix in project */
- #define DEFAULT_FMT FMT_GIF
- #endif
-
-
- /* DATA GATHERED FROM THE DJPEG DIALOG */
- typedef struct {
- Boolean smoothing;
- Boolean grayscale;
- Boolean quantize;
- short colors;
- Boolean onepass;
- Boolean nodither;
- short debug;
- FSSpec outfile;
- Boolean replace_ok;
- ImageFormat format;
- } djpeg_dlog_data;
-
-
- /* DATA GATHERED FROM THE CJPEG DIALOG */
- typedef struct {
- short quality;
- Boolean grayscale;
- Boolean targa;
- Boolean optimize;
- Boolean arithmetic;
- Boolean nointerleave;
- FSSpec outfile;
- Boolean replace_ok;
- short debug;
- } cjpeg_dlog_data;
-
- /* PREFERENCES DATA */
- #define PREF_VERSION 1
- typedef struct {
- short pref_version;
- Point progressLoc;
- OSType jpeg_type;
- OSType jpeg_creator;
- OSType gif_type;
- OSType gif_creator;
- OSType ppm_type;
- OSType ppm_creator;
- OSType targa_type;
- OSType targa_creator;
- OSType rle_type;
- OSType rle_creator;
- Boolean overwrite;
- Boolean show_all;
- } prefs_data, **PrefHandle;
-
-
- /* PROTOTYPES OF ROUTINES */
-
- GLOBAL void
- Error (OSErr eCode, unsigned char *p1, unsigned char *p2);
-
- GLOBAL short
- display_djpeg_dialog (FSSpec infile, djpeg_dlog_data *dlog_info);
-
- GLOBAL short
- display_cjpeg_dialog (FSSpec infile, cjpeg_dlog_data *dlog_info);
-
- GLOBAL void
- display_prefs_dialog (void);
-
- GLOBAL void
- fix_name (Str255 outname, Str255 inname, int format);
-
- GLOBAL OSErr
- FSSpecToName (FSSpec spec, Str255 fullname);
-
- GLOBAL void
- CenterDialog (short id, Point *corner);
-
- GLOBAL void
- PutFile (ConstStr255Param prompt, ConstStr255Param defaultName, StandardFileReply *reply);
-
- GLOBAL pascal void
- NOPRoutine (WindowPtr dwind, short dinum);
-
- GLOBAL pascal void
- BorderDefault (WindowPtr dwind, short dinum);
-
- GLOBAL Boolean
- ReturnEnterEscape (DialogPtr d, EventRecord *theEvent, short *item);
-
- GLOBAL void
- read_preference_file (void);
-
- GLOBAL Handle
- ditemh (DialogPtr theDialog, short item);
- #define CITEMH(d, i) (ControlHandle)ditemh(d, i)
-
- GLOBAL void
- DoAboutBox (void);
-
- GLOBAL OSErr
- xFSMakeFSSpec (short vRefNum, long dirID, ConstStr255Param fileName, FSSpecPtr spec);
-
- GLOBAL OSErr
- xFSpCreateResFile (const FSSpec *spec, OSType creator, OSType fileType, ScriptCode scriptTag);
-
- GLOBAL short
- xFSpOpenResFile (const FSSpec *spec, SignedByte permission);
-
- pascal OSErr
- SetDialogDefaultItem (DialogPtr theDialog, short newItem) = {0x303C, 0x0304, 0xAA68};
-
- pascal OSErr
- SetDialogCancelItem (DialogPtr theDialog, short newItem) = {0x303C, 0x0305, 0xAA68};
-
- pascal OSErr
- GetStdFilterProc (ModalFilterProcPtr *theProc) = {0x303C, 0x0203, 0xAA68};
-
- pascal OSErr
- SetDialogTracksCursor (DialogPtr theDialog, Boolean tracks) = {0x303C, 0x0306, 0xAA68};
-
-
- /* Stuff for Pascal type strings ... */
-
- #define CSTR char *
- #define PSTR unsigned char *
-
- /* concatonate 2 Pascal strings: a = CONCAT(b, c). Assumes Str255. Truncates if necessary. */
- #define CONCAT(a, b, c) do { int cchars; \
- cchars = ((int)b[0] + (int)c[0] > 255 ? 255 - b[0] : c[0]); \
- if (&a[0] == &b[0]) { \
- BlockMove(&c[1], &a[a[0]+1], cchars); \
- a[0] += cchars; \
- } else { \
- BlockMove(&c[1], &a[1 + b[0]], cchars); \
- BlockMove(&b[1], &a[1], b[0]); \
- a[0] = b[0] + cchars; \
- } \
- } while (0)
- #define COPY(target, source) BlockMove(source, target, *source+1);
-